package com.gongzhiyun.springboot3test.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gongzhiyun.springboot3test.base.PageBean;
import com.gongzhiyun.springboot3test.base.R;
import com.gongzhiyun.springboot3test.entity.TbApi;
import com.gongzhiyun.springboot3test.mapper.TbApiMapper;
import com.gongzhiyun.springboot3test.service.TbApiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
public class TbApiServiceImpl implements TbApiService {
    private final TbApiMapper tbApiMapper;

    @Override
    public R<List<TbApi>> query(PageBean pageBean) {
        Page<TbApi> pages = tbApiMapper.selectPage(new Page<>(pageBean.getPageNum(), pageBean.getPageSize()), null);
        pageBean.setPages(pages.getPages());
        pageBean.setTotal(pages.getTotal());
        R<List<TbApi>> r = R.ok(pages.getRecords());
        r.setPageBean(pageBean);
        return r;
    }
}
